<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <div id="div">
        <div>
            {{fn}}
        </div>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    const app = new Vue({
        el: '#div',
        data: {
            a: 1,
            b: 2
        },
        // 在computed中定义方法，返回计算属性
        computed: {
            fn() {
                return this.a + this.b
            }
        }

    })
</script>

</html>